home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / Libraries / 3DGPL 1.0 / CODE / ENGINE / ENG-BASE.C next >
Encoding:
C/C++ Source or Header  |  1997-03-08  |  2.7 KB  |  63 lines  |  [TEXT/MACA]

  1. /** 3DGPL *************************************************\
  2.  *  ()                                                    *
  3.  *  Header for the 3D engine.                             *
  4.  *                                                        *
  5.  *  Defines:                                              *
  6.  *   M_render_polygon        rendering a generic polygon; *
  7.  *                                                        *
  8.  *  (6/1995) By Sergei Savhenko. (savs@cs.mcgill.ca).     *
  9.  *  Copyright (c) 1995 Sergei Savchenko.                  *
  10.  *  THIS SOURCE CODE CAN'T BE USED FOR COMERCIAL PURPOSES *
  11.  *  WITHOUT AUTHORISATION                                 *
  12. \**********************************************************/
  13.  
  14. #ifdef __MWERKS__
  15. #include "hardware.h"           /* fast memory moves */
  16. #include "graphics.h"           /* 2-D rendering */
  17. #include "trans.h"                 /* 3-D transformations */
  18. #include "clipper.h"             /* 2-D/3-D clipping */
  19. #include "engine.h"               /* 3-D engine */
  20. #else
  21. #include "../hardware/hardware.h"           /* fast memory moves */
  22. #include "../graphics/graphics.h"           /* 2-D rendering */
  23. #include "../trans/trans.h"                 /* 3-D transformations */
  24. #include "../clipper/clipper.h"             /* 2-D/3-D clipping */
  25. #include "../engine/engine.h"               /* 3-D engine */
  26. #endif
  27.  
  28. /**********************************************************\
  29.  *  Rendering a generic polygon in perspective.           *
  30. \**********************************************************/
  31.  
  32. void M_render_polygon(struct M_polygon *poly,int *vertex,int *vectors)
  33. {
  34.  int tmp1[M_POLYGON_LENGTH_LIMIT],tmp2[M_POLYGON_LENGTH_LIMIT];
  35.  int *tuples1=tmp1,*tuples2=tmp2,number,cnd;
  36.  
  37.  if((cnd=C_volume_clipping(poly->m_edges,tuples1,vertex,poly->m_id,
  38.                            1+(number=poly->m_no_edges)))!=0)
  39.  {
  40.   if(cnd==-1) number=C_polygon_z_clipping(tuples2=tmp1,tuples1=tmp2,
  41.                                           poly->m_id,number
  42.                                          );
  43.   T_perspective(tuples1,tuples2,poly->m_id,number+1);
  44.   switch(poly->m_id)
  45.   {
  46.    case M_AMBIENT: G_ambient_polygon(tuples2,number,poly->m_colour);
  47.                    break;
  48.    case M_SHADED:  G_shaded_polygon(tuples2,number);
  49.                    break;
  50.    case M_TEXTURED:G_textured_polygon(tuples2,number,tuples1,
  51.                                       &vectors[poly->m_u_index],
  52.                                       &vectors[poly->m_v_index],
  53.                                       poly->m_texture,
  54.                                       poly->m_log_texture_size,
  55.                                       poly->m_log_texture_scale
  56.                                      );
  57.                    break;
  58.   }
  59.  }
  60. }
  61.  
  62. /**********************************************************/
  63.